Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create problem

 
Tomasz Wilk
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have a problem with create method. I have many complex solutions but none simple What I want to do (am doing) is I have a map in data class
containing deleted rows. In create method I check if there are any rows which I can reuse. If there are, I take one. If not I extend a database size. I lock a record create it and unlock it. I decided to allow only one
creation thread at a time - method is synchronized on createMutex object.
Here comes a problem - I dont want to use this createMutex. But if I will not use this there can be a problem when there are no row ids to be reused.
Both threads will extend a database. If second will start writting first it will write far outside the file and exception will be thrown. Anybody has idea how to avoid this problem?
 
Chris Be
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomasz,

Use the keep-it-simple principle: do not allow reusing of records. It is not a must requirement, and complicates the matter not insignificantly. Many great test scores were achieved without reuse.

Refer to this link for my 2 cents worth of what may need to be observed for create.

ChrisBe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic