Hi Guys,

There are a few threads last week that covers area of Worker and Disk file 
access. So, I’m just going to choose this one to reply.

If I may, I’d like to offer a different approach in implementation for the 
custom logging using Workers. In order to avoid a race condition while allowing 
messages to be record rapidly, I would suggest the following approach.

The worker method will perform 2 tasks: 1. Record a new message and 2. Flush 
recorded messages on the disk.

When a new message is sent to the worker, it will be recorded in a process 
object variable (C_OBJECT). For example:

{
     “1” : “Message 1 ABC”,
     “2” : “Message 2 DEF”,
     “3” : “Message 3 GHI”
}

Notice that the object property is a sequence number. You will increment for 
each message that you are recording.

To save this messages to the disk, you will have to run a background process 
that continues to tell the worker to flush the current set of messages (in the 
Object variable) to the disk. For each message that you sent to the disk, you 
will remove it from the Object variable. Because object is based on reference, 
you can just call the command OB REMOVE to do that job. Next will just have to 
save the last sequence in a process variable and use it to test against the 
data in the Object variable next time the call to flush is made.

Anyway, I have put together a prototype based on what I just described. It 
seems to be working pretty well. I will find the best way to share it with you 
all on Monday. I might turn it into a tech note as well.

Regards,
Add K.





**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**********************************************************************

Reply via email to